# coding:utf-8
from odoo import models, fields, api, _
from odoo.exceptions import Warning
import odoo.addons.decimal_precision as dp
from odoo.exceptions import UserError


class HrEmployee(models.Model):
    _inherit = 'hr.employee'

    @api.multi
    def name_get(self):
        res = []
        for emp in self:
            name = emp.user_id.login and '[%s] %s' % (emp.user_id.login, emp.name) or emp.name or ''

            res.append((emp.id, name))
        return res

    @api.multi
    def write(self, vals):
        res = super(HrEmployee, self).write(vals)
        for emp in self:
            emp.user_id.department_id = emp.department_id
        return res